<%@ page language="java" contentType="text/html; charset=utf-8" import="com.bjsxt.shopping.user.*"
    pageEncoding="utf-8"%>

<%
String action = request.getParameter("action");
if(action != null && action.equals("login")) {
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	User u = null;
	try {
		u = User.check(username, password);
	} catch (UserNotFoundException e) {
		out.println(e.getMessage());
		return;
	} catch (PasswordNotCorrectException e) {
		out.println(e.getMessage());
		return;
	}

	session.setAttribute("user", u);
	session.setAttribute("loginname", u.getLoginname());
	
	String userType = u.getAcctype();
	String userStatus = u.getStatus();
	
	//客户
	if(userType.equals("1")){
		response.sendRedirect("AccIndex.jsp");
	}
	//管理员
	if(userType.equals("0")){
		response.sendRedirect("AdminIndex1.jsp");
	}	
	//翻译审核员
	if(userType.equals("4")){
		response.sendRedirect("TransAudit.jsp");
	}
	//译者
	if(userType.equals("2")){
	   if(userStatus.equals("1")){
	   //审核已通过
			response.sendRedirect("ShowProducts111.jsp");
		}else if(userStatus.equals("0")){
			out.println("您的注册资料还未通过管理员审核,请耐心等待。");
			return;
		}else if(userStatus.equals("2")){
			out.println("您的注册试题未通过管理员审核,请重新翻译试题并提交注册！");
			return;
		}

	}
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>欢迎来到众译快翻平台！</title>
</head>
<body>
	
	<div  style="background:#99ccff; color:#000; height:80px; text-align:center; line-height:80px;   ">
	<font size="8" style="font-weight:bold;color:black;font-style:italic;  ">众译快翻</font>
	</div>	
	
	<div  style="background:#ffffff; color:#000; height:20px;  ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;欢迎来到众译快翻平台！</div>	
	<table border="0" align="center">
		<tr>
			<td>
				<div  style="background:#ffffff; color:#000;   ">
				<br><br><br><br>
					<img src="images/wzfy1.png" height="100" width="100">
				</div>	
			</td>
	
			<td>
			<div>
				<form  method="post" action="" onSubmit="this.regsubmit.disabled=true;">
					<input type="hidden" name="action" value="login"/>
					<table border="1" align="center">
						<tr>
							<br><br><br><br>
						</tr>
						<tr>
							<td>用户名:</td>
							<td><input type="text" size="20" name="username"/></td>
						</tr>
						<tr>
							<td>密码:</td>
							<td><input type="password" size="20" name="password"/></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" value="登录"/></td>
						</tr>
					</table>
				
				</form>
			</div>	
			</td>
	</tr>
</table>
</body>
</html>